package util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.mysql.cj.Query;


public class Jdbcutil {
	

	private static final String URL = "jdbc:mysql://localhost:3306/ems?useSSL=false&serverTimezone=UTC";
	private static final String USERNAME = "root";
	private static final String PWD = "1234";
	
	
	
	private Jdbcutil(){}
	
	public static Connection getConn() throws SQLException, ClassNotFoundException{       //建立数据库的连接
		
		return DriverManager.getConnection(URL,USERNAME,PWD);
	}
	
	public  static void  close(	Connection conn) {  			  //假如连接还存在，则关闭该连接
		if(conn != null) {
			try {
				conn.close();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}	
}